package cn.edu.scau.cmi.liujiaming.chapter04;

import java.util.Arrays;
import java.util.Scanner;

public class ExampleOn1 {

	public static void main(String[] args) {
		Scanner reader=new Scanner(System.in);
		System.out.print("输入需要产生的随机数的数目n：");
		int n=reader.nextInt();
		reader.close();
		int[] a=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=(int)(Math.random()*1000);
		}
		System.out.printf("产生的%d个随机数为",n);
		
		int max=a[0];
		for(int b:a) {
			System.out.print(b+" ");
			if(b>max) {
				max=b;
			}
		}
		System.out.println();
		System.out.println("最大值为"+max);
		Arrays.sort(a);
		System.out.print("升序排序后为"+Arrays.toString(a));
	}

}